package common

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/common"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// PreAuthQueryService 预授权查询服务
type PreAuthQueryService struct {
	*services.BaseService
}

// NewPreAuthQueryService 创建预授权查询服务
func NewPreAuthQueryService(config *core.Config) *PreAuthQueryService {
	return &PreAuthQueryService{
		BaseService: services.NewBaseService(config),
	}
}

// PreAuthQuery 预授权查询
func (s *PreAuthQueryService) PreAuthQuery(request *common.PreAuthQueryRequest) (*common.PreAuthQueryResponse, error) {
	response := common.NewPreAuthQueryResponse()
	err := s.Post(request, response, "/open/trans/preauthquery")
	if err != nil {
		return nil, err
	}
	return response, nil
}
